{-# LANGUAGE TypeOperators, RankNTypes #-}
{- |
Module      :  Types
Description :  <optional short text displayed on contents page>
Copyright   :  (c) Sergey Sichevskiy 2012
License     :  BSD3

Maintainer  :  s.sichevskij@gmal.com
Stability   :  experimental
Portability :  portable

Определение различных типов

-}

module Types
 ( SED
 , Response
 , Extinction
 , Factory
 , Context(..)
 , Resp(..)
 , Integrator(..)
 , ModelFlux(..)
 , FittingMethod(..)
 ) where

import Model                ( Teff, Logg )

import Data.HList           ( (:::), Null )
import Data.BFunction       ( (:~>:) )
import Control.Monad.Reader ( ReaderT )

type SED        = Double :~>: Double
type Response   = Double :~>: Double
type Extinction = Double :~>: Double

type Factory  = ReaderT Context IO

data Context  = Context { response   :: Resp
                        , extinction :: Extinction
                        , modelflux  :: ModelFlux
                        , integrator :: Integrator
                        , fitmethod  :: FittingMethod
                        }

data Resp = Resp {
                 -- 2MASS survey
                   j_twomass :: Response
                 , h_twomass :: Response
                 , k_twomass :: Response
                 -- DENIS survey
                 , i_denis   :: Response
                 , j_denis   :: Response
                 , k_denis   :: Response
                 -- WBVR survey
                 , w_wbvr    :: Response
                 , b_wbvr    :: Response
                 , v_wbvr    :: Response
                 , r_wbvr    :: Response
                 }

data Integrator = Integrator { bound :: (Double, Double)
                             , step  :: Double
                             , quad  :: (Double :~>: Double) -> Double
                             }

data ModelFlux = Pickles  { classI   :: (Double -> SED, Double -> Double)
                          , classIII :: (Double -> SED, Double -> Double)
                          , classV   :: (Double -> SED, Double -> Double)
                          }
--               | Castelli { flux     :: (Double -> Double -> SED, (Double,Double) -> (Double,Double))
--                          }
               | Castelli { flux     :: Teff ::: Logg ::: Null -> SED
                          , domain   :: [ [Teff:::Logg:::Null] ]
                          }

data FittingMethod = FittingMethod { maxIterations :: Int
                                   , absTolerance  :: Double
                                   , relTolerance  :: Double
                                   }